#!/usr/env/bin python
# -*- coding: utf-8 -*-

# @Time    : 2019/12/30 22:04|22:04
# @Author  : yangdingyi
# @File    : 根据字符出现频率排序
# @Software: PyCharm


class Solution:
    def frequencySort(self, s: str) -> str:
        from collections import Counter
        c = Counter(s)
        ll = list(map(lambda a: a*c[a], sorted(c, key=lambda x: -c[x])))
        return ''.join(ll)


solve = Solution()
# s = "Aabb"
s = "raaeaedere"
print(s)
print('ans:', solve.frequencySort(s))


